export default {
  namespaced: true,
  state: {
    menus: [],
    activeMenu: '',
    openSubmenus: [],
    moduleName: 'index'
  },
  getters: {
    menus (state) {
      return state.menus
    },
    activeMenu (state) {
      return state.activeMenu
    },
    openSubmenus (state) {
      return state.openSubmenus
    },
    moduleName (state) {
      return state.moduleName
    }
  },
  mutations: {
    SET_MENU (state, menus) {
      state.menus = menus
    },
    SET_ACTIVE_MENU (state, activeMenu) {
      state.activeMenu = activeMenu
    },
    SET_OPEN_SUBMENUS (state, openSubmenus) {
      state.openSubmenus = openSubmenus
    },
    SET_MODULE_NAME (state, moduleName) {
      state.moduleName = moduleName
    }
  },
  actions: {
    setPageMenu ({ commit }, { menus, activeMenu, openSubmenus, moduleName }) {
      commit('SET_MENU', menus)
      commit('SET_ACTIVE_MENU', activeMenu)
      commit('SET_OPEN_SUBMENUS', openSubmenus)
      commit('SET_MODULE_NAME', moduleName)
      return Promise.resolve()
    },
    changeModuleName ({ commit }, moduleName) {
      commit('SET_MODULE_NAME', moduleName)
      return Promise.resolve()
    }
  }
}
